package indi.zn.commons.easiness;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.common.base.Strings;


public class Dates {

	public static final String FORMAT_DATE="yyyy-MM-dd";
	public static final String FORMAT_DATETIME="yyyy-MM-dd HH:mm:ss";

	public static final DateFormat datef=new SimpleDateFormat(FORMAT_DATE);
	public static final DateFormat dateTimef=new SimpleDateFormat(FORMAT_DATETIME);
	
	public static DateFormat getDateFormat(String format){
		
	if(Strings.isNullOrEmpty(format)){
		return  new SimpleDateFormat();
	}else{
	
		return  new SimpleDateFormat(format);
	  
	}
	}
	
	
	
	public static String formatDate(Date d){
		
		return datef.format(d);
		
	}
	
	public static String formatDateTime(Date d){
		
		return dateTimef.format(d);
		
	}
	
	public static Date parseDateTime(String d) throws ParseException{
		
		return dateTimef.parse(d);
		
	}
	
	public static Date parseDate(String d) throws ParseException{
		
		return datef.parse(d);
		
	}
	
	public static String NowDateStr(){
		
		return getDateFormat(FORMAT_DATE).format(new Date());

	}

    public static Date NowDate(){
		
		return new Date();

	}
    
    public static String NowTimeStr(){
		
		return getDateFormat(FORMAT_DATETIME).format(new Date());

	}
	
	
}
